#include <stdio.h>
#include <string.h>

int main()
{
    int num_rooms, price;
    while (scanf("%d %d", &num_rooms, &price) == 2)
    {
        int i, total_area = 0, bedroom_area = 0, balcony_area = 0;
        for (i = 0; i < num_rooms; i++)
        {
            int area;
            char room[10];
            scanf("%d %s", &area, room);
            total_area += area;
            if (strcmp(room, "bedroom") == 0)
                bedroom_area += area;
            else if (strcmp(room, "balcony") == 0)
                balcony_area += area;
        }
        printf("%d\n", total_area);
        printf("%d\n", bedroom_area);
        price *= (total_area * 2 - balcony_area);
        printf("%d%s\n", price / 2, (price % 2 == 0? "" : ".5"));
    }
    return 0;
}
